﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Inspiration.Web.Controllers
{
    public class SearchController : Controller
    {
        //
        // GET: /Search/
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(FormCollection formValues)
        {
            string searchTerm = formValues["SearchTerm"];
            Inspiration.Web.Models.InspirationEntities entitiesRepository = new Models.InspirationEntities();
            IEnumerable<Inspiration.Web.Models.Idea> ideas = entitiesRepository.Ideas.Where(ideasRepo => ideasRepo.Name.Contains(searchTerm));
            return View("List", ideas);
        }
    }
}
